package name.cyh.dubbo;

import com.alibaba.fastjson2.JSON;
import name.cyh.model.to.CommitOrder;
import name.cyh.service.InventoryServiceImpl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 18433
 */
@DubboService
public class InventoryDubboServiceImpl implements InventoryDubboService {

    private static final Logger LOGGER =
            LoggerFactory.getLogger(InventoryDubboServiceImpl.class);

    @Resource
    private InventoryServiceImpl inventoryService;

    @Override
    public void inventoryLocking(String commitOrderListToString) {
        LOGGER.info("扣减库存接口");
        List<CommitOrder> commitOrdersList = JSON.parseArray(commitOrderListToString, CommitOrder.class);
        inventoryService.inventoryLocking(commitOrdersList);
    }

    @Override
    public void inventoryLocking(List<CommitOrder> commitOrderListList) {
        LOGGER.info("扣减库存接口");
        inventoryService.inventoryLocking(commitOrderListList);
    }

}
